<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<div class="line-big">
	<div class="xl1"></div>
	<div class="xl10">
		<div class="panel border-back" id="write_comment_info_div">
			<div class="panel-body text-center">
				<h1>
					<strong>回复卖家评论</strong>
				</h1>
			</div>
			<div class="panel-foot bg-white border-back">
				<input type="hidden" id="commentId" value="${comment.commentId }">
				<div class="line-big margin-big-top">
					<div class="xl7">
						<div class="label">
							<label for="peopleName">评价内容:</label>
						</div>
						<div class="field">${comment.commentContent }</div>
					</div>
					<div class="xl5">
						<div class="label">
							<label for="">描述相符：</label> <span data-score="${comment.commentDescriptionStar }" id="commentDescriptionStar" class="star"></span>
						</div>
						<div class="label">
							<label for="">服务态度：</label> <span data-score="${comment.commentServiceStar }" id="commentServiceStar" class="star"></span>
						</div>
						<div class="label">
							<label for="">发货速度：</label> <span data-score="${comment.commentDeliverStar }" id="commentDeliverStar" class="star"></span>
						</div>
						<div class="label">
							<label for="">物流速度：</label> <span data-score="${comment.commentLogisticsStar }" id="commentLogisticsStar" class="star"></span>
						</div>
						<div class="label">
							<label for="">快递员态度：</label> <span data-score="${comment.commentCourierStar }" id="commentCourierStar" class="star"></span>
						</div>
					</div>
				</div>
				<c:choose>
					<c:when test="${comment.commentReply==null }">
						<hr>
						<div class="line-big margin-big-top">
							<div class="xl7">
								<div class="label">
									<label for="peopleName">*回复内容(10-400字):</label>
								</div>
								<div class="field">
									<textarea rows="5" class="input" id="commentReply" placeholder="回复内容" data-regex="^\S.{8,398}\S$"></textarea>
								</div>
							</div>
							<div class="xl5"></div>
						</div>
					</c:when>
					<c:otherwise>
						<hr>
						<div class="line-big margin-big-top">
							<div class="xl7">
								<div class="label">
									<label for="peopleName">回复内容:</label>
								</div>
								<div class="field">${comment.commentReply }</div>
							</div>
							<div class="xl5"></div>
						</div>
					</c:otherwise>
				</c:choose>
			</div>
			<c:if test="${comment.commentReply==null }">
				<div class="panel-foot bg-white">
					<div class="line-big margin-top margin-bottom">
						<div class="xl4"></div>
						<div class="xl4 text-center">
							<button class="button border-blue" id="submit_comment_button">回复评论</button>
						</div>
						<div class="xl4"></div>
					</div>
				</div>
			</c:if>
		</div>
		<div id="add_success_div" class="G-MarginTop100" style="display: none;">
			<div class="line-big">
				<div class="xl3"></div>
				<div class="xl6 text-center">
					<h1 class="text-center">
						<span class="icon-check-circle text-yellow"></span> 回复评论成功了。
					</h1>
					<br />
					<p>
						<button class="button bg-green click_go_to_nav_button" data-trigger-id="#sub_see_to_be_done_order">
							<span class="icon-eye"></span> 去查看已完成的订单
						</button>
					</p>
				</div>
				<div class="xl3"></div>
			</div>
		</div>
	</div>
	<div class="xl1"></div>
</div>
<div style="display: none" id="time_temp_div"></div>

<!-- 星级评分效果插件 -->
<script type="text/javascript" src="js/jquery.raty.js"></script>
<script type="text/javascript">
	$(function()
	{
		$(".star").each(function()
		{
			var star_obj = $(this);
			star_obj.raty(
			{
				hints : [ '失望', '不满', '一般', '满意', '惊喜' ],
				path : 'images/',
				number : 5,
				size : 32,
				score : star_obj.attr("data-score"),
				readOnly : true
			});
		});

		$("#submit_comment_button").click(function()
		{
			var commentId = $("#commentId").val();
			var commentReply = $("#commentReply").val();

			if (commentReply.length <= 0)
			{
				alert("标有*的输入项都是必填项.")
				return false;
			}

			var tips = "";
			var tips_number = 1;
			$.each([ $("#commentReply") ], function(i, n)
			{
				if (new RegExp(n.attr("data-regex")).test(n.val()) == false)
				{
					tips += tips_number++ + " . \"" + n.val() + "\" 不满足输入要求;\n";
				}
			});
			if (tips.length > 0)
			{
				alert(tips + "\n请检查一下重新输入.");
				return false;
			}

			var submit_comment_button_html = $("#submit_comment_button").html();
			$.ajax(
			{
				url : "${basePath}admin/m_add_new_comment_do",
				type : "POST",
				dataType : "json",
				beforeSend : function(XMLHttpRequest)
				{
					$("#submit_comment_button").attr("disabled", "disabled");
					$("#submit_comment_button").html("正在提交回复评论中...");
				},
				data :
				{
					'comment.commentId' : commentId,
					'comment.commentReply' : commentReply
				},
				success : function(json, textStatus)
				{
					if (json.success == true)
					{
						$("#write_comment_info_div").slideUp();
						$("#add_success_div").slideDown(function()
						{
							$(".admin").animate(
							{
								scrollTop : 0
							}, 0);
						});

					}
					else
					{
						alert(json.info);
					}
				},
				error : function(XMLHttpRequest, textStatus, errorThrown)
				{
					alert("提交失败，请仔细检查您的输入是否满足要求。");
				},
				complete : function(XMLHttpRequest, textStatus)
				{
					$("#submit_comment_button").removeAttr("disabled");
					$("#submit_comment_button").html(submit_comment_button_html);
				}
			});
		});
	});
</script>